package com.struts.business;

import com.struts.service.Action;
import com.struts.service.JudgeService;
import com.struts.service.JudgeServiceImpl;
import com.struts.vo.UserinfoVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2015/2/5.
 */
public class JudgeAction implements Action {

    @Override
    public String exexut(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) {
         String url="";
        String text = httpServletRequest.getParameter("text");
        JudgeService judgeService = new JudgeServiceImpl();
        Map<String,UserinfoVO> map = judgeService.getVO(text);
        Set<String> set = map.keySet();
        for (Iterator<String> iterator = set.iterator(); iterator.hasNext();){

            url = iterator.next();
            httpServletRequest.setAttribute("meg",map.get(url));
        }

        /* UserinfoVO userinfoVO = new UserinfoVO();
       boolean b = this.isUserinfo(text);
       if (b){

           userinfoVO.setU_name("success");
           userinfoVO.setU_pass("success");
           userinfoVO.setU_age("1");

           url="/view/view.jsp";
       }else {
           userinfoVO.setU_name("error");
           userinfoVO.setU_pass("error");
           userinfoVO.setU_age("0");
          // request.setAttribute("meg","error");
           url="/view/error.jsp";
       }*/
      //  httpServletRequest.setAttribute("meg",userinfoVO);
        return url;
    }
 /*   private  boolean isUserinfo(String userinfo){

        boolean b =false;

        if(userinfo.equals("lxd")){

            b = true;
        }
        return b;
    }*/

}
